package mydemo.springcloudalibaba.provide.payment.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import lombok.extern.slf4j.Slf4j;
import mydemo.springcloudalibaba.api.common.entity.CommonResult;
import mydemo.springcloudalibaba.api.common.entity.Payment;
import mydemo.springcloudalibaba.provide.payment.service.PaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/payment")
@Slf4j
public class PaymentController {
    @Value("${server.port}")
    private String serverPost;
    @Autowired
    private PaymentService paymentService;
    @Autowired
    private DiscoveryClient discoveryClient;


    @RequestMapping("/get/{id}")
    public CommonResult getPaymentById_success(@PathVariable("id") Long id) {
        return new CommonResult(200, "成功", paymentService.getPaymentById_success(id));
    }
    @RequestMapping("/error/{id}")
    @HystrixCommand
    public CommonResult getPaymentById_error(@PathVariable("id") Long id) {
        return new CommonResult(200, "成功", paymentService.getPaymentById_error(id));
    }

}
